====================================================================== Microsoft Product Support Services Application Note (Text File) DV0599: COMPILING AND LINKING QUESTIONS AND ANSWERS ====================================================================== Revision Date: 8/92 No Disk Included The following information applies to Microsoft Visual Basic for MS-DOS version 1.0. -------------------------------------------------------------------- | INFORMATION PROVIDED IN THIS DOCUMENT AND ANY SOFTWARE THAT MAY | | ACCOMPANY THIS DOCUMENT (collectively referred to as an | | Application Note) IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY | | KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO | | THE IMPLIED WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A | | PARTICULAR PURPOSE. The user assumes the entire risk as to the | | accuracy and the use of this Application Note. This Application | | Note may be copied and distributed subject to the following | | conditions: 1) All text must be copied without modification and | | all pages must be included; 2) If software is included, all files | | on the disk(s) must be copied without modification [the MS-DOS(R) | | utility DISKCOPY is appropriate for this purpose]; 3) All | | components of this Application Note must be distributed together; | | and 4) This Application Note may not be distributed for profit. | | | | Copyright 1992 Microsoft Corporation. All Rights Reserved. | | Microsoft and MS-DOS are registered trademarks and Visual Basic | | and Windows are trademarks of Microsoft Corporation. | -------------------------------------------------------------------- 1. Q. How do I modify a Quick library? A. It is not possible to modify an existing Quick library. To add routines to a Quick library, you must re-create it. For more information on how to create a Quick library, please refer to Chapter 19 of the "Programmer's Guide." 2. Q. LINK.EXE (the linker) continues to generate the error message "R6907 DOSX16: not enough memory on exec." What is causing this error? A. LINK.EXE version 5.31.009, which is provided with Microsoft Visual Basic for MS-DOS, tries to use expanded and extended memory by default. If either type of memory is low, that is, less than 200K is available, it is possible that the linker can fail and generate the error message "R6907 DOSX16: not enough memory on exec." To work around this error, use the /r switch as the first option on the link line; /r must immediately follow "LINK" for this switch to be effective. The Visual Basic for MS-DOS (VBDOS) environment, VBDOS.EXE, checks for this condition and adds /r to the link line for you. This forces the linker to ignore expanded and extended memory and run in conventional memory only. To work around this problem without using the /r switch, you must make more expanded and/or extended memory available to the linker. This may involve changing the settings for your expanded memory manager. If you are running Visual Basic in an MS-DOS session within Microsoft Windows, you must change the PIF settings for that MS-DOS session. 3. Q. My program runs in the Microsoft Visual Basic for MS-DOS (VBDOS) environment; however, when the program is compiled, an "out of memory" message is generated. How can I correct this problem? A. If a program runs successfully in the VBDOS environment but runs out of memory at compile time or run time, there may be a problem with arrays. In the VBDOS environment, arrays are dynamic by default. This means that the arrays are created at run time and are stored in far memory. In a compiled application, arrays are static by default. This means the arrays are created at compile time and are stored in near memory (DGROUP), of which there is only 64K. To make all your arrays dynamic in a compiled application, use the metacommand REM $DYNAMIC at the beginning of your program before the dimension (DIM) statements of your arrays. If you have any arrays that are included in COMMON SHARED statements, the DIM statements in which they are included. For more information on the $DYNAMIC command, please refer to the "A-Z Reference" in the "Reference" manual. For more information on memory management, please refer to Appendix B of the "Programmer's Guide." 4. Q. When I try to compile my program, I receive a "program memory overflow" error message. How can I correct this problem? A. If a program runs successfully in the Visual Basic for MS-DOS (VBDOS) environment but generates a "program memory overflow" error message at compile time, the program needs to be broken down into multiple modules. In the VBDOS environment, each subroutine, function, event, or module-level code is allocated 64K for code. In a compiled application, the entire file is allocated only 64K. This difference allows a much larger code module or form to run in the environment than can run in a compiled application. To make your compiled programs run, you must reduce them in size by moving some code to another module. For more information on multiple-module programming, please refer to Chapters 6 and 16 of the "Programmer's Guide."